<!doctype html>
<html>license
<head>
  <meta charset="utf-8">
  <title>检查结果上报</title>


  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui" />
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="format-detection" content="telephone=no, email=no" />

  <link rel="stylesheet" href="../resource/weuimin.css" />
  <link rel="stylesheet" href="../resource/example.css" />
  <link  href="../resource/style.css" rel="stylesheet" type="text/css">
  <script src="../script/common.js" type="text/javascript" > </script>
  <script src="../resource/html5shiv.min.js"></script>
  <script src="../resource/jquery214.js"></script>
  <script src="../resource/fastclick.js"></script>
  <script src="../resource/jqueryweui.js"></script>
  <script src="../resource/zeptomin.js"></script>
  <script src="../resource/picker.js"></script>
  <script src="../resource/pickercity.js"></script>
  <script src="../script/api.js"></script>
  <script>
    var count =1;
    $.weui = {};
    $.weui.alert = function(options){
      options = $.extend({title: '警告', text: '警告内容'}, options);
      var $alert = $('.weui_dialog_alert');
      $alert.find('.weui_dialog_title').text(options.title);
      $alert.find('.weui_dialog_bd').text(options.text);
      $alert.on('touchend click', '.weui_btn_dialog', function(){
        $alert.hide();
      });
      $alert.show();
    };


    apiready = function () {
       if(api.systemType == "ios"){
		   document.getElementById("statusBar").style.background = "#298cb4";
		}
       $api.fixStatusBar( $api.dom('header') );
       document.getElementById("dw_name").value = $api.getStorage('dw_name');   
       document.getElementById("gaid").value = $api.getStorage('dwid');         
       document.getElementById("name").value = $api.getStorage('name');         
       document.getElementById("dw_code").value = $api.getStorage('dw_code');   
       document.getElementById("dw_sf").value = $api.getStorage('dw_sf');       
       document.getElementById("garyid").value = $api.getStorage('id');         

       $("#filename0").val("现场照片");

      }

function getPicture(id){
      api.getPicture({
                sourceType: 'camera', 
                encodingType: 'jpg',         //jpg格式  ，设png无效。。。。
                mediaValue: 'pic',
                destinationType: 'base64',
                quality: 100,
                targetWidth: 400,           
                targetHeight: 600,
                saveToPhotoAlbum: false    //是否保存到相册
              },
              function(ret, err) {
                if (ret) {

                  if (ret.data != "") {
                    var ba= ret.base64Data.replace("data:image/jpeg;base64,", "");        //去文件头字符串
                        ba= ba.replace("data:image/jpg;base64,", "");         //去文件头字符串   
                    $("#pic1a").val(ba);
                  //  console.info('xxxx='+document.getElementById("pic1a").value);
                  //  alert('yyy='+ret.base64Data.substring(0,25));
                    
                    $('#'+ id + '_show').html('');
                   var pic = $('<li class="weui_uploader_file weui_uploader_status" onclick="getPicture(\''+id+'\')"  style="margin-left:5px;width:100px;height:150px;background-image:url(' + ret.base64Data + ')"><div class="weui_uploader_status_content></div></li>');
                    $('#'+ id + '_show').append(pic);
                    $('#'+ id + '_show').show();
                    $('#filename0').hide();
                    $('#'+ id + '_img').hide();
                    $('#'+ id).hide();
                  }
                } else {
                  alert("调用摄像头失败...");
                }
              });
    }

  
  
  </script>

  <style>
    .jcjgclass{
                margin: 10px;  /* 外边框*/
    }     
    textarea {
                padding: 10px;
                border: 1px solid #ccc;
                color: #000;
                font-size: 16px;
                height: 100px;
                width: 100%;
                box-sizing: border-box;
            }
     .btn-1 a {width: 90%;outline: none;border: none;background: #18b4ed;color: #fff;height: 4rem;line-height: 4rem;display: inline-block;border-radius: 0.4rem;font-size: 2rem;}      
      
     .scanbnclass{
                margin: 3px 10px;
                background: #18b4ed;
                height: 40px;
                line-height: 40px;
                text-align: center;
                font-size: 20px;
                margin-top: 5px;
                border-radius: 5px;
                color: #fff;
            }      
            
    .logo-license{
                  margin-top:0px;
                  }
    .left{font-weight:bold;  }
    .info {margin-top: 5rem; }

    .weui_cells_form input, .weui_cells_form label[for], .weui_cells_form textarea {-webkit-tap-highlight-color: rgba(0,0,0,0);}
    .weui_uploader_input {position: absolute;z-index: 1;top: 0;left: 0; width: 100%;height: 100%;opacity: 0;-webkit-tap-highlight-color: rgba(0,0,0,0);}
    .weui_uploader_input_wrp {float: left;position: relative;margin-right: 9px;margin-bottom: 9px;width: 77px;height: 77px;border: 1px solid #d9d9d9;}
    .weui_uploader_files {list-style: none;}
    .weui_uploader_file {font-size: 12px;color: #333;text-align: center;display: table-cell;vertical-align: middle;display: table;}
    .weui_uploader_file {float: left;margin-right: 9px;margin-bottom: 9px;width: 79px; height: 79px;background: no-repeat 50%;background-size: cover;}
    .info ul li .weui_uploader_files{width:99px;height:99px;}
    .js_file_show{display:none;}
    #ssk{background-color:#FFFFFF;width: 93%;height: 5rem;font-size:2rem;}
    /*地址样式*/
    #divselect .all li{line-height:2rem;padding:5px 1rem;text-indent:0;}
    .half > a img {
      text-align: center;
      width: 15rem;
      height:15rem;
       margin-left: 0rem;
       margin-top: 0rem;
    }
  /*  .half > a{background:none;}*/
     .half > a{background:none;}
    
    
    .jcbiaoti{
                float:left;
                width:47%;
             
                background:#18b4ed;
                text-align: center;  
                height: 40px;   
                line-height: 40px;   

                font-size: 16px;
           /*     margin-top: 5px;      */
                border-radius: 5px;
                color:  #fff
            }   
  .jcbiaoti2{
                float:left;
                width:47%;
                margin: 0px 8px;
                background: #18b4ed;
                text-align: center;   
                height: 40px;
                line-height: 40px;

                font-size: 16px;
         /*       margin-top: 5px;    */
                border-radius: 5px;
                color: #fff;
            } 
  .jcbiaoti3{
                float:left;
             
                 margin: 5px 8px;
                background:#18b4ed;
                text-align: center;  
                height: 40px;   
                line-height: 40px;   
                font-size: 20px;
           /*     margin-top: 5px;      */
                border-radius: 5px;
                color:  #fff
            }
 .jcbiaoti4{
               float:left;
                width:210PX;
                margin: 5px 0px;
                background:#18b4ed;
                text-align: center;  
                height: 40px;   
                line-height: 40px;   

                font-size: 18px;
           /*     margin-top: 5px;      */
                border-radius: 5px;
                color:  #fff
            }   
  .juzhong
            {
            text-align:center
            }  
  .uploader {
    position: absolute;
    width: 54%;
    height: 0 rem;
    left: 32%;
    cursor: default;
    height: 10%;
    float: left;
}          
.filename {
   /* position: absolute;
    outline: 0 none;*/
    line-height: 1.5rem;
    font-size: 1.5rem;
    color: #999;
    width: 60%;
    margin: 0;
    overflow: hidden;
    cursor: default;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: 100%;
    top: 9.2rem;
    text-align: center;

}             
  </style>

</head>



<body>
<header style="z-index:999" id="statusBar">
  <img onclick="javascript :history.back(-1);" src="../resource/images/rpwbackn.png"/>
  <span>检查结果上报</span>
  <div class="clear"></div>
</header>

<form id="form" method="post" enctype="multipart/form-data">


  <input id="dw_name"    name="dw_name"    type="hidden" />                    <!--登录单位名称-->
  <input id="gaid"       name="gaid"       type="hidden" />                    <!--登录单位ID-->
  <input id="name"       name="name"       type="hidden" />                    <!--登录人员姓名-->
  <input id="dw_code"    name="dw_code"    type="hidden" />                    <!--登录单位代码-->
  <input id="dw_sf"      name="dw_sf"      type="hidden" />                    <!--  自动执行，将登录 人员所属单位身份填入-->
  <input id="garyid"     name="garyid"     type="hidden" />                    <!--  登录 人员ID-->

  <input id="pic1a"      name="jczp"       type="hidden" />                     <!--照片数据-->
  <input id="jcsminfo"   name="jcsminfo"   type="hidden" />                     <!--检查扫描数据（二维码）-->


  <article class="info">
    <ul>
		 <li>
			<div class="jcbiaoti">
			 &nbsp;从业人员检查：
			</div>
			<div class="jcbiaoti2">
			<input type="radio" value="0" id="ryjc" name="ryjc"  checked="checked"/>合格
			<input type="radio" value="1" id="ryjc" name="ryjc" />不合格
			</div>
			<div class="clear"></div>
		</li>
		
		 <li>
			<div class="jcbiaoti">
			 &nbsp;安全防范检查：
			</div>
			<div class="jcbiaoti2">
			<input type="radio" value="0" id="aqff" name="aqff" checked="checked"/>合格
			<input type="radio" value="1" id="aqff" name="aqff" />不合格
			</div>
			<div class="clear"></div>
		</li>
		
		<li>
			<div class="jcbiaoti">
			 &nbsp;技防监控检查：
			</div>
			<div class="jcbiaoti2">
			<input type="radio" value="0" id="jfjk" name="jfjk" checked="checked"/>合格
			<input type="radio" value="1" id="jfjk" name="jfjk"/>不合格
			</div>
			<div class="clear"></div>
		</li>
		
		<li>
			<div class="jcbiaoti">
			 &nbsp;消防安全检查：
			</div>
			<div class="jcbiaoti2">
			<input type="radio" value="0" id="xfaq" name="xfaq" checked="checked"/>合格
			<input type="radio" value="1" id="xfaq" name="xfaq"/>不合格
			</div>
			<div class="clear"></div>
		</li>
		
		<li>
			<div class="jcbiaoti">
			 &nbsp;黄赌毒情况：
			</div>
			<div class="jcbiaoti2">
			<input type="radio" value="0" id="hdd" name="hdd" checked="checked"/>合格
			<input type="radio" value="1" id="hdd" name="hdd"/>不合格
			</div>   
			<div class="clear"></div>
		</li>
		
		<li>
			<div class="jcbiaoti">
			 &nbsp;可疑情况：
			</div>
			<div class="jcbiaoti2">
			<input type="radio" value="0" id="kyqk" name="kyqk" checked="checked"/>无&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<input type="radio" value="1" id="kyqk" name="kyqk"/>有
			</div>   
			<div class="clear"></div>
		</li>
		
		<li>
			<div class="jcbiaoti">
			 &nbsp;处理结果：
			</div>
			<div class="jcbiaoti2">
			<select id="cljg" name="cljg" style="width:150px;height:40px;"> 
			        <option value="0" selected="selected">无</option> 
                    <option value="1">口头警告</option> 
                    <option value="2">口头勒令整改</option> 
                    <option value="3">当场罚款</option> 
                    <option value="4">普通程序处罚</option> 
                    <option value="5">其他</option> 

                    </select>
			</div>
			<div class="clear"></div>
		</li>

		<li>
		<div class="jcbiaoti3">
			&nbsp;备注： 
		</div>
		
         <div class="jcjgclass">
              <textarea id="jcnr" name="jcnr" placeholder="备注..." onpropertychange="if(value.length>2000) value=value.substr(0,2000)"  ></textarea>
         </div>
         <div class="clear"></div>
         </li>
       
       
       
      <li>

	            <div class="uploader">
	              <ul id="pic1_show"  class="weui_uploader_files js_file1_show">
	              </ul>
	              <input type="text" id="filename0" class="filename" readonly/>
	              
                    <a id="pic1_img" class="license js_file1_license" style="margin-top:-9rem;position: absolute !important;" onclick="getPicture('pic1')" >
                    
	                <img id="img-1" src="../resource/images/logon.png"/>    
	              </a>
	              
	             <input id="pic1" type="button" name="pic1" class="js_file1" size="30" />
	            </div>


     			<div class="half" style="float:right;">
     			<a class="logo" id="logox">
				</a>
     			 <p>&nbsp;</p>
			    </div>
				 <div class="clear"></div>
  
      </li>
      
      
 </ul>
 
 
  </article>




<div id="loadingToast" style="display:none;">
    <div class="weui-mask_transparent"></div>
    <div class="weui-toast">
        <i class="weui-loading weui-icon_toast"></i>
        <p class="weui-toast__content">数据加载中……</p>
    </div>
</div>


	  <article class="btn-1">
	    <a onclick="scanner()">扫描二维码上传检查情况</a>
	</article>
					  
	</form>
</body>

<script>
  
  function check() {      
                    //基本信息验证
		    var jcsminfo = document.getElementById("jcsminfo").value;                                        //二维码数据如果 为空
		    if (jcsminfo == null || jcsminfo == "") {
		      alert("二维码检查没有扫描!");
		      return false;
		     }


			if(document.getElementById("pic1a").value==null||document.getElementById("pic1a").value==""){     //照片数据验证
			       alert("请上传检查现场照片！");
			       return false;
			     }

	  return true;        //如果以上都 通过，返回T
	 
	  }


function scanner(){
				 var FNScanner = api.require('FNScanner');
				 FNScanner.openScanner({
		   		 autorotation: true,
					}, function(ret, err) {

                 if (ret) {
					  var getinfo=ret.content;

						if(getinfo!=null){
							var dktime=getinfo.substring(14);  		//截取前14个字符，只保留后面的打卡时间	“q151050000001,2017-09-21 09:00:28”			
							api.confirm({
								    title: '上传扫描结果？',
								    msg: "检查时间:"+dktime,
								    buttons: ['确定', '取消']
								}, function(ret, err) {
									if(ret.buttonIndex==1){     //如果返回为1（确定）  2是取消  （从右到左的顺序）
										document.getElementById("jcsminfo").value = getinfo ; 
									    jcsb();                //调用sbdk()
									    }
								});	
						  }						
				    } else {    //如果是取值失败
						       alert(JSON.stringify(err));
						    	}
						     });
			     	}


  function jcsb() {                    //提交注册
	     var a = check();              //进行表单检验
		 if(a){
	            $("#loadingToast").show();

			api.ajax({ 
		            url: Serverip + '/base/syuser!doNotNeedSessionAndSecurity_SaveJCXX.sy',
		            method: 'post',
					dataType: 'json',
	            
		            data: { 
					            values:{
								    dw_name:document.getElementById("dw_name").value,
								    gaid:document.getElementById("gaid").value,
								    name:document.getElementById("name").value,
								    dw_code:document.getElementById("dw_code").value,
								    dw_sf:document.getElementById("dw_sf").value,
								    garyid:document.getElementById("garyid").value,
								    jczp:document.getElementById("pic1a").value,       //.....照片
								    jcsminfo:document.getElementById("jcsminfo").value,	
									
								    ryjc:document.getElementById("ryjc").value,
								    aqff:document.getElementById("aqff").value,
								    jfjk:document.getElementById("jfjk").value,
								    xfaq:document.getElementById("xfaq").value,	
								    hdd:document.getElementById("hdd").value,
								    kyqk:document.getElementById("kyqk").value,
								    cljg:document.getElementById("cljg").value,
								    jcnr:document.getElementById("jcnr").value
								       }, 

			
                          },
		            timeout: 30,
                  }, function(ret, err) { 


				    if (ret) {
				                $("#loadingToast").hide();
				        
				        		 switch(ret.returninfo){ 
				
					              case 0: 
							              alert("检查结果上报成功！");
						                  location.href='guser.html';
					 	                  break;   
					 	                  
					              case 1:
						                 alert("检查结果上报失败!请系统管理员联系！");
						                 location.href='guser.html';
						                 break; 
						                 
				 	              case 2:
						                 alert("检查结果上报失败!该单位信息不存在！");
						                 location.href='guser.html';
						                 break; 
						          case 3:
						                 alert("检查结果上报失败!该单位已经注销！");
						                 location.href='guser.html';
						                 break; 
						                } 
				        
				    }else {
				         $("#loadingToast").hide();
                         api.alert({msg:('错误码：'+err.code+'；错误信息：'+err.msg+'网络状态码：'+err.statusCode)}); 
				           };
                 });

		     }//end if
		    
       } //end
  
</script>

</html>